package practice;

public class _二叉树的镜像_ {
    public static void main(String[] args) {
        _二叉树的镜像_ c = new _二叉树的镜像_();
        Solution s = c.getSolution();
        TreeNode n1 = new TreeNode(8);
        TreeNode n2 = new TreeNode(6);
        TreeNode n3 = new TreeNode(10);
        TreeNode n4 = new TreeNode(5);
        TreeNode n5 = new TreeNode(7);
        TreeNode n6 = new TreeNode(9);
        TreeNode n7 = new TreeNode(11);
        n1.left = n2;
        n1.right = n3;
        n2.left = n4;
        n2.right = n5;
        n3.left = n6;
        n3.right = n7;
        s.Mirror(n1);
        System.out.println("finish.");
    }

    Solution getSolution() {
        return new Solution();
    }

    class Solution {
        public void Mirror(TreeNode root) {
            if (root == null) return;
            TreeNode temp = root.left;
            root.left = root.right;
            root.right = temp;
            Mirror(root.left);
            Mirror(root.right);
        }
    }
}
